package loltimer;

import java.awt.Dimension;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import javax.swing.JDialog;
import org.jnativehook.GlobalScreen;

public class Loltimer extends Application {

    public static void main(final String[] args) {

        try {

            launch(args);


        } catch (Exception exception) {
            exception.printStackTrace();
        }

    }

    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("Embedded Media Player");
        Group root = new Group();
        final Scene scene = new Scene(root);

//        stage.setScene(scene);
//        stage.show();
        //System.out.println(new File(Loltimer.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "img/GolemSquare.png").exists());
        InputStream pathblue = getClass().getClassLoader().getResourceAsStream("resources/GolemSquare.png");
        Image imageblue = new Image(pathblue, 50, 50, true, true);
        ImageView imageViewblue = new ImageView();
        imageViewblue.setImage(imageblue);
        root.getChildren().add(imageViewblue);

        InputStream pathred = getClass().getClassLoader().getResourceAsStream("resources/LizardSquare.png");
        Image imagered = new Image(pathred, 50, 50, true, true);
        ImageView imageViewred = new ImageView();
        imageViewred.setImage(imagered);
        imageViewred.relocate(50, 0);
        root.getChildren().add(imageViewred);

        InputStream pathdragon = getClass().getClassLoader().getResourceAsStream("resources/DragonSquare.png");
        Image imagedragon = new Image(pathdragon, 50, 50, true, true);
        ImageView imageViewdragon = new ImageView();
        imageViewdragon.setImage(imagedragon);
        imageViewdragon.relocate(100, 0);
        root.getChildren().add(imageViewdragon);

        InputStream pathbaron = getClass().getClassLoader().getResourceAsStream("resources/Baron_Nashor.png");
        Image imagebaron = new Image(pathbaron, 50, 50, true, true);

        ImageView imageViewbaron = new ImageView();
        imageViewbaron.setImage(imagebaron);
        imageViewbaron.relocate(150, 0);
        root.getChildren().add(imageViewbaron);

        Label timeblue = new Label("");
        timeblue.setMinSize(50, 50);
        timeblue.setAlignment(Pos.CENTER);
        timeblue.setFont(Font.font("Cambria", FontWeight.BOLD, 28));
        timeblue.setTextFill(Color.RED);
        root.getChildren().add(timeblue);
        
        Label timered = new Label("");
        timered.setMinSize(50, 50);
        timered.setAlignment(Pos.CENTER);
        timered.setFont(Font.font("Cambria", FontWeight.BOLD, 28));
        timered.setTextFill(Color.RED);
        timered.relocate(50, 0);
        root.getChildren().add(timered);
        
        Label timedragon = new Label("");
        timedragon.setMinSize(50, 50);
        timedragon.setAlignment(Pos.CENTER);
        timedragon.setFont(Font.font("Cambria", FontWeight.BOLD, 28));
        timedragon.setTextFill(Color.RED);
        timedragon.relocate(100, 0);
        root.getChildren().add(timedragon);
        
        Label timenashor = new Label("");
        timenashor.setMinSize(50, 50);
        timenashor.setAlignment(Pos.CENTER);
        timenashor.setFont(Font.font("Cambria", FontWeight.BOLD, 28));
        timenashor.setTextFill(Color.RED);
        timenashor.relocate(150, 0);
        root.getChildren().add(timenashor);

        //timeblue.setText("top");
       GlobalScreen.getInstance().addNativeKeyListener(new KeyListener(timeblue,timered,timedragon,timenashor));
        
        JDialog jDialog = new JDialog();
        jDialog.setUndecorated(true);
        final JFXPanel fxPanel = new JFXPanel();
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                fxPanel.setScene(scene);
            }
        });
        jDialog.add(fxPanel);
        jDialog.setMinimumSize(new Dimension(200, 50));
        jDialog.setLocation(300, 0);
        jDialog.setAlwaysOnTop(true);
        jDialog.setVisible(true);
    }
    
    
}
